home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / sudo-1.000 / sudo-1 / sudo-1.2 / sudo.h < prev    next >
C/C++ Source or Header  |  1993-12-05  |  6KB  |  213 lines

  1. /*
  2.  *  sudo version 1.1 allows users to execute commands as root
  3.  *  Copyright (C) 1991  The Root Group, Inc.
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 1, or (at your option)
  8.  *  any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with this program; if not, write to the Free Software
  17.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  If you make modifications to the source, we would be happy to have
  20.  *  them to include in future releases.  Feel free to send them to:
  21.  *      Jeff Nieusma                       nieusma@rootgroup.com
  22.  *      3959 Arbol CT                      (303) 447-8093
  23.  *      Boulder, CO 80301-1752             
  24.  */
  25.  
  26. /*        The following macros can be defined when compiling
  27.  
  28.           FQDN                   - if you have fully qualified hostnames
  29.                                    in your SUDOERS files
  30.  
  31.           SYSLOG                 - if you want to use syslog instead
  32.                                    of a log file
  33.                    ( This is a nice feature.  You can 
  34.                      collect all you sudo logs at a
  35.                      central host.  The default is for
  36.                      sudo to log at the local2 facility. )
  37.  
  38.           SEND_MAIL_WHEN_NOT_OK  - if you want a message sent to ALERTMAIL
  39.                                    when the user is in the SUDOERS but
  40.                                    does not have permission to execute
  41.                                    the command entered
  42.                    ( This can be used at paranoid sites )
  43.  
  44.           SEND_MAIL_WHEN_NO_USER - if you want a message sent to ALERTMAIL
  45.                    when the user is not in the SUDOERS file
  46.                    ( This is generally the case )
  47.  
  48. */
  49.  
  50.  
  51. #ifndef TIMEDIR
  52. #define TIMEDIR "/tmp/.odus"
  53. #endif
  54.  
  55. #ifndef TIMEOUT
  56. #define TIMEOUT 5
  57. #endif
  58.  
  59. #ifndef TRIES_FOR_PASSWORD
  60. #define TRIES_FOR_PASSWORD 3
  61. #endif
  62.  
  63. #ifndef INCORRECT_PASSWORD
  64. #define INCORRECT_PASSWORD "Sorry, try again."
  65. #endif
  66.  
  67. /*
  68.  *  If the MAILER macro is changed make sure it will work in
  69.  *  logging.c  --  there is some sendmail mail specific stuff in
  70.  *  the send_mail() routine  ( e.g.  the argv for the execv() )
  71.  *  MAILER should ALWAYS be fully quallified.
  72.  */
  73.  
  74. #ifndef MAILER
  75. #define MAILER "/usr/lib/sendmail"
  76. #endif
  77.  
  78. #ifndef MAILSUBJECT
  79. #define MAILSUBJECT "*** SECURITY information ***"
  80. #endif
  81.  
  82. #ifndef ALERTMAIL
  83. #define ALERTMAIL "root"
  84. #endif
  85.  
  86. #ifndef SUDOERS
  87. #define SUDOERS "/etc/sudoers"
  88. #endif
  89.  
  90. #ifndef TMPSUDOERS
  91. #define TMPSUDOERS "/etc/stmp"
  92. #endif
  93.  
  94. #ifndef EDITOR
  95. #define EDITOR "/usr/bin/vi"
  96. #endif
  97.  
  98. #ifndef MAXHOSTNAMELEN
  99. #define MAXHOSTNAMELEN 64
  100. #endif
  101.  
  102. #define MAXCOMMANDLENGTH         0x030
  103.  
  104. typedef union {
  105.     int int_val;
  106.     char char_val[MAXCOMMANDLENGTH];
  107.     } YYSTYPE;
  108.  
  109. typedef struct list {
  110.     int type;
  111.     char op;
  112.     char *data;
  113.     struct list *next;
  114.     } LIST, *LINK;
  115.  
  116. YYSTYPE yylval, yyval;
  117.  
  118.  
  119.  
  120.  
  121. #ifdef SYSLOG   /* SYSLOG should be defined in the makefile */
  122. #include <syslog.h>
  123. #ifndef Syslog_ident
  124. #define Syslog_ident        "sudo"
  125. #endif
  126. #ifndef Syslog_options
  127. #define Syslog_options      LOG_PID
  128. #endif
  129. #ifndef Syslog_facility
  130. #define Syslog_facility     LOG_LOCAL2
  131. #endif
  132. #ifndef Syslog_priority_OK
  133. #define Syslog_priority_OK  LOG_NOTICE
  134. #endif
  135. #ifndef Syslog_priority_NO  
  136. #define Syslog_priority_NO  LOG_ALERT
  137. #endif
  138. #else
  139. #ifndef LOGFILE
  140. #if defined(ultrix) || defined(sun) || defined(LINUX)
  141. #define LOGFILE "/var/adm/sudo.log"
  142. #else
  143. #define LOGFILE "/usr/adm/sudo.log"
  144. #endif  /* /var vs. /usr */
  145. #endif  /* LOGFILE */
  146. #endif  /* SYSLOG  */
  147.  
  148.                        /* Maximum number of characters to log per entry. */
  149. #ifndef MAXLOGLEN      /* The syslogger will log this much, after that,  */
  150. #define MAXLOGLEN 990  /* it truncates the log line. We need this here   */
  151. #endif                 /* to make sure that we get ellipses when the log */
  152.                /* line is longer than 990 characters.            */
  153.  
  154.  
  155. #define VALIDATE_OK              0x00
  156. #define VALIDATE_NO_USER         0x01
  157. #define VALIDATE_NOT_OK          0x02
  158. #define VALIDATE_ERROR          -1
  159.  
  160. /*
  161.  *  the arguments passed to log_error() are ANDed with GLOBAL_PROBLEM
  162.  *  If the result is TRUE, the argv is NOT logged with the error message
  163.  */
  164.  
  165. #define GLOBAL_PROBLEM           0x20
  166. #define GLOBAL_NO_PW_ENT         ( 0x01 | GLOBAL_PROBLEM )
  167. #define GLOBAL_NO_HOSTNAME       ( 0x02 | GLOBAL_PROBLEM )
  168. #define GLOBAL_HOST_UNREGISTERED ( 0x03 | GLOBAL_PROBLEM )
  169. #define PASSWORD_NOT_CORRECT     0x04
  170. #define ALL_SYSTEMS_GO           0x00
  171. #define NO_SUDOERS_FILE          ( 0x05 | GLOBAL_PROBLEM )
  172.  
  173. #define TRUE                     0x01
  174. #define FALSE                    0x00
  175.  
  176. #define TYPE1                    0x11
  177. #define TYPE2                    0x12
  178. #define TYPE3                    0x13
  179.  
  180. #define FOUND_USER               0x14
  181. #define NOT_FOUND_USER           0x15
  182. #define MATCH                    0x16
  183. #define NO_MATCH                 0x17
  184. #define QUIT_NOW                 0x18
  185. #define PARSE_ERROR              0x19
  186.  
  187. #define USER_LIST                0x00
  188. #define HOST_LIST                0x01
  189. #define CMND_LIST                0x02
  190. #define EXTRA_LIST               0x03
  191.  
  192. /* These are the functions that are called in sudo */
  193. char *find_path();
  194. char *strdup();
  195. void load_globals();
  196. void log_error();
  197. void inform_user();
  198. void check_user();
  199. int validate();
  200.  
  201. /* Most of these variables are declared in main() so they don't need
  202.  * to be extern'ed here if this is main...
  203.  */
  204. #ifndef MAIN
  205. extern short uid;
  206. extern char *host;
  207. extern char *user;
  208. extern char *cmnd;
  209. extern char **Argv;
  210. extern int  Argc;
  211. #endif
  212. extern int errno;
  213.